/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Buildings.java
 *
 * Created on 18.05.2011, 21:48:16
 */

package siedleronlineproxy.forms.buildings;

import javax.swing.JScrollPane;
import siedleronlineproxy.constants.Building;
import siedleronlineproxy.constants.Building.BuildingCategory;


/**
 *
 * @author nspecht
 */
public class Buildings extends javax.swing.JPanel {
    BuildingTable[] tables = new BuildingTable[Building.BuildingCategory.values().length];

    private static Buildings instance = null;
    public static Buildings getInstance() {
        return Buildings.instance;
    }

    /** Creates new form Buildings */
    public Buildings() {
        initComponents();
        Buildings.instance = this;

        for(Building.BuildingCategory cat : Building.BuildingCategory.values()) {
            JScrollPane scroll = new javax.swing.JScrollPane();
            this.tables[cat.ordinal()] = new siedleronlineproxy.forms.buildings.BuildingTable();
            if (cat!=cat.ALL) this.tables[cat.ordinal()].addFilter(cat);
            scroll.setViewportView(this.tables[cat.ordinal()]);
            this.buildingCategoryTab1.setItem(cat, scroll);
        }
    }

    public void forceUpdate() {
        for(BuildingTable t : this.tables) {
            t.forceUpdate();
        }
    }

    public void update() {
        for(BuildingTable t : this.tables) {
            t.update();
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        jLabel1 = new javax.swing.JLabel();
        buildingCategoryTab1 = new siedleronlineproxy.forms.BuildingCategoryTab();

        setName("Form"); // NOI18N
        setLayout(new java.awt.GridBagLayout());

        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(siedleronlineproxy.SiedlerOnlineProxyApp.class).getContext().getResourceMap(Buildings.class);
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        add(jLabel1, gridBagConstraints);

        buildingCategoryTab1.setTabPlacement(javax.swing.JTabbedPane.LEFT);
        buildingCategoryTab1.setName("buildingCategoryTab1"); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        add(buildingCategoryTab1, gridBagConstraints);
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private siedleronlineproxy.forms.BuildingCategoryTab buildingCategoryTab1;
    private javax.swing.JLabel jLabel1;
    // End of variables declaration//GEN-END:variables

}
